package com.helper.dream.a361phonehelper.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.helper.dream.a361phonehelper.R;
import com.helper.dream.a361phonehelper.bean.SuperViseBean;
import com.helper.dream.a361phonehelper.utils.L;
import com.helper.dream.a361phonehelper.widget.CircleImage;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/23.
 */

public class SuperviseContentAdapter extends RecyclerView.Adapter<SuperviseContentAdapter.AboutHolder> {
    List<SuperViseBean.DataBean> list;
    Context context;
    LayoutInflater layoutInflater;

    public SuperviseContentAdapter(List<SuperViseBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public AboutHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.supervise_item_content_layout, parent, false);
        return new AboutHolder(view);
    }

    @Override
    public void onBindViewHolder(AboutHolder holder, int position) {
        SuperViseBean.DataBean dataBean = list.get(position);
        Picasso.with(context)
                .load(dataBean.getLogo())
                .transform(new CircleImage())
                .into(holder.iv);
        holder.title.setText(dataBean.getTitle());
        holder.subTitle.setText(dataBean.getDesc());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class AboutHolder extends RecyclerView.ViewHolder{
        ImageView iv;
        TextView title, subTitle;
        TextView btn;
        public AboutHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.super_content_iv);
            title = (TextView) itemView.findViewById(R.id.super_content_title);
            subTitle = (TextView) itemView.findViewById(R.id.super_content_subTitle);
            btn = (TextView) itemView.findViewById(R.id.super_content_btn);
        }
    }
}
